import time

from Finance_fun.base.base import Base
from Finance_fun import page

class Page(Base):
    """注册页面操作"""
    #点击注册
    def page_click_register_link(self):
        self.base_click(page.register_link)

    #输入手机号
    def page_input_register_phone(self,phone):
        self.base_input(page.register_phone,phone)

    #获取输入的手机号
    def page_get_register_phone(self):
        self.base_get_text(page.register_phone)

    #输入密码
    def page_input_register_password(self,password):
        self.base_input(page.register_password,password)

    #输入验证码
    def page_input_register_verify_code(self,verify_code):
        self.base_input(page.register_verify_code,verify_code)

    #点击获取验证码
    def page_click_register_get_phone_code(self):
        self.base_click(page.register_get_phone_code)

    ##输入手机获取的验证码
    def page_input_register_phone_code(self, phone_code):
        self.base_input(page.register_phone_code, phone_code)

    #同意协议
    def page_click_register_read_terms(self):
        self.base_click(page.register_read_terms)

    #注册按钮
    def page_click_register_btn(self):
        self.base_click(page.register_btn)

    #注册成功时的手机号信息（右上角）
    def page_get_register_success_inf(self):
        return self.base_get_text(page.register_success)

    #手机错误提示
    def page_get_register_phone_err_inf(self):
        return self.base_get_text(page.register_phone_error)

    #密码错误提示
    def page_get_register_password_err_inf(self):
        return self.base_get_text(page.register_password_error)

    #验证码错误
    def page_get_register_verify_code_err_inf(self):
        return self.base_get_text(page.register_verify_code_error)

    #页面已更新，无弹窗
    def page_get_register_phone_code_err_alert(self):
        return self.base_get_text(page.register_alert)

    """截图操作"""
    def page_get_screenshot(self):
        self.base_get_image()

    # 集成注册操作
    def page_register(self, phone, password, verify_code, phone_code):
        # self.page_click_register_link()
        self.page_input_register_phone(phone)
        self.page_input_register_password(password)
        self.page_input_register_verify_code(verify_code)
        self.page_click_register_get_phone_code()
        sleep(3)
        self.page_input_register_phone_code(phone_code)
        # self.page_click_register_read_terms() 默认已点击
        sleep(2)
        self.page_click_register_btn()


    # 集成注册操作不点击注册按钮
    def page_register_no_click(self, phone, password, verify_code, phone_code):
        # self.page_click_register_link()
        self.page_input_register_phone(phone)
        self.page_input_register_password(password)
        self.page_input_register_verify_code(verify_code)
        sleep(3)
        self.page_input_register_phone_code(phone_code)
        # self.page_click_register_read_terms()
        sleep(2)
        self.page_click_register_btn()